package util

import (
	"litter-api/app/util/pool"
	"time"
)

var BaseKey = "cpmart|account|redis|lock|"

func Lock(key string) bool {

	key = BaseKey + key
	if pool.Redis.Exists(key) {
		return true
	}

	pool.Redis.Set(key, "1", 60 *time.Second)
	return false
}

func UnLock(key string) {
	pool.Redis.Del(BaseKey + key)
}